
let open = false
let shot = false
$('.t-user').focus(function(){
    $(this).css('border', '2px solid #000');
});
$('.t-user').blur(function(){
    $(this).css('border', '1px solid #f5f5f5');
    if(!($(".t-user").value = this.value.replace(/\s/,''))){
        // alert('账户名不能为空')
        $('.worry').html('账户名不能为空')
        open = false
    }else{
        $('.worry').html('')
        open = true
    }
});
$('.t-word').focus(function(){
    $(this).css('border', '2px solid #000');
});
$('.t-word').blur(function(){
    $(this).css('border', '1px solid #f5f5f5');
    if(!($(".t-word").value = this.value.replace(/\s/,''))){
        $('.worry1').html('密码不能为空')
        shot = false
    }else{
        $('.worry1').html('')
        shot = true
    }
});
$('.t-sign').click(function(){
    if(open&&shot){
        pAjax({
            url: '../server/login.php',
            type: 'post',
            data: {
                username: $('.t-user').val(),
                password: $('.t-word').val()
            }
        }).then(function (res) {
            console.log(res)
            let json = JSON.parse(res)
            console.log(json)
            if (json.code === 0) {
                window.location.href = '../index.html'
                // 存token
                localStorage.setItem('username', $('.t-user').prop('value'))
            }

            alert(json.msg)
        })
    }else{
        alert('账户名   密码不能为空')
    }
});
$('.s-endcon p').find('span').mouseenter(function(){
    $(this).css({
        color:' #FF6700'
    })
})
$('.s-endcon p').find('span').mouseleave(function(){
    $(this).css({
        color:' #555'
    })
})
